/**
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Autogenerated file -- DO NOT EDIT!

// CC-OFFNXT(huge_method,huge_cyclomatic_complexity,G.FUN.01-CPP) big switch-case, solid logic
const char *TokenToString(TokenType type)  // NOLINT(readability-function-size)
{
    switch (type) {
%   allTokens = Tokens::tokens + Keywords::keywords
%   allTokens.each do |token|
        case TokenType::<%= token.token %>:
            return "<%= token.string %>";
%   end
        case TokenType::LITERAL_IDENT:
            return "identification literal";
        case TokenType::LITERAL_NUMBER:
            return "number literal";
        case TokenType::LITERAL_STRING:
            return "string literal";
        case TokenType::LITERAL_CHAR:
            return "char literal";
        case TokenType::JS_DOC_START:
            return "/**";
        case TokenType::JS_DOC_END:
            return "*/";
        case TokenType::EOS:
            return "end of stream";
        default:
            ES2PANDA_UNREACHABLE();
    }
}

% genSwitch = lambda do |var, tokens, flag|
    switch (<%= var %>) {
%   tokens.select { |token| token.flags&.include? flag }.each do |token|
        case TokenType::<%= token.token %>:
%   end
            return true;
        default:
            return false;
    }
% end

bool Token::IsUnary() const
{
%    genSwitch['type_', allTokens, 'unary']
}

bool Token::IsReservedTypeName() const
{
%    genSwitch['keywordType_', Keywords::keywords, 'reserved_type_name']
}

bool Token::IsDefinableTypeName() const
{
%    genSwitch['keywordType_', Keywords::keywords, 'definable_type_name']
}

bool Token::IsBinaryToken(TokenType type)
{
%    genSwitch['type', allTokens, 'binary']
}

bool Token::IsBinaryLvalueToken(TokenType type)
{
%    genSwitch['type', Tokens::tokens, 'binary_lvalue']
}

bool Token::IsPredefinedType() const
{
%    genSwitch['keywordType_', Keywords::keywords, 'predefined_type']
}
